import pkuseg
import gensim
import re
import openpyxl

excel_file="C://Users//滑稽鸭阁//Documents//Tencent Files//1160636624//FileRecv//ad表格.xlsx"
wb = openpyxl.load_workbook(excel_file)
sh= wb['工作表1']

seg = pkuseg.pkuseg(model_name='default',user_dict = "D://皮炎参数//血常规.txt")
dict_ige = dict()
with open('D://皮炎参数//血常规.txt',encoding='utf-8') as f:
    lines = f.readlines()
f.close()
size=0
for line in lines:
    line = line.strip('\n')
    dict_ige[str(line)]=size
    size=size+1
print(dict_ige)

b=[0]*23
stop=[]
with open('D://皮炎参数//血常规停用词.txt',encoding='utf-8') as f:
    lines = f.readlines()
    for line in lines:
        line = line.strip('\n')
        print(str(line))
        stop.append(str(line))

for i in range(2,202):
    b=[0]*23
    s= str(sh.cell(i,23).value)
    for l in stop: 
        s=s.replace(l,' ')
    print(s)
    text=seg.cut(s)
    text.append('。')
    for ch in range(0,len(text)):
        if text[ch] in dict_ige.keys():
            if re.search(r'\d', text[ch+1] ):
                b[dict_ige[text[ch]]]=text[ch+1]
            else :b[dict_ige[text[ch]]]=1
    print(b)
    print(text)
